<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('房源信息列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <!--<li>-->
                                <!--<label>装修：</label>-->
                                <!--<select name="renovationId" class="form-control m-b" >-->
                                    <!--<option value="">所有</option>-->
                                    <!--<option th:each="dict : ${renovationList}" th:text="${dict.name}" th:value="${dict.id}"></option>-->
                                <!--</select>-->
                            <!--</li>-->
                            <!--<li>-->
                                <!--<label>类型：</label>-->
                                <!--<select name="typeId" class="form-control m-b" >-->
                                    <!--<option value="">所有</option>-->
                                    <!--<option th:each="dict : ${typeList}" th:text="${dict.name}" th:value="${dict.id}"></option>-->
                                <!--</select>-->
                            <!--</li>-->
                            <li>
                                <label>状态：</label>
                                <select name="stat" class="form-control m-b" th:with="type=${@dict.getType('house_status')}">
                                    <option value="1,3,4">所有</option>
                                    <option value="1">通过</option>
                                    <option value="3">已卖出</option>
                                    <option value="4">已下架</option>
                                </select>
                            </li>
                            <li>
                                <label>独家房源：</label>
                                <select name="sole" class="form-control m-b"  th:with="type=${@dict.getType('house_sole')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="type" class="form-control m-b" th:with="type=${@dict.getType('house_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system/house:house:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system/house:house:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system/house:house:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system/house:house:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-warning" id="importExcel">
                    <i class="fa fa-download"></i> 导入EXCEL
                </a>
                <a class="btn btn-warning" onclick="$.table.importZip()" shiro:hasPermission="system/house:house:export">
                    <i class="fa fa-download"></i> 导入压缩包
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system/house:house:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system/house:house:remove')}]];
        var statusDatas = [[${@dict.getType('house_status')}]];
        var soleDatas = [[${@dict.getType('house_sole')}]];
        var typeDatas = [[${@dict.getType('house_type')}]];
        var prefix = ctx + "system/house/house";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                modalName: "房源信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'memberName',
                    title: '推荐人姓名',
                    formatter: function (value,row,index) {
                        if(value==null){
                            return "系统添加";
                        }
                        return value;
                    }
                },
                {
                    field: 'memberMobile',
                    title: '推荐人手机号'
                },
                {
                    field: 'name',
                    title: '名称'
                },
                // {
                //     field: 'renovation',
                //     title: '装修'
                // },
                // {
                //     field: 'type',
                //     title: '类型'
                // },
                // {
                //     field: 'orientation',
                //     title: '朝向'
                // },
                // {
                //     field: 'years',
                //     title: '年代'
                // },
                // {
                //     field: 'address',
                //     title: '地址'
                // },
                {
                    field: 'price', 
                    title: '售价(单位：万)'
                },
                {
                    field: 'priceOne', 
                    title: '单价(单位：元)'
                },
                {
                    field: 'houseRoom', 
                    title: '户型',
                    formatter: function(value, row, index) {
                        return row.houseRoom+"室-"+row.houseLivingRoom+"厅-"+row.houseToilet+"卫";
                    }
                },
                {
                    field: 'area', 
                    title: '面积'
                },
                {
                    field: 'floor', 
                    title: '楼层',
                    formatter: function(value, row, index) {
                        return row.floor+"/"+row.floorMax;
                    }
                },
                {
                    field: 'status', 
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'sole', 
                    title: '独家房源',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(soleDatas, value);
                    }
                },
                {
                    field: 'type', 
                    title: '类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });



        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;

            //普通图片上传
            upload.render({
                elem: '#importExcel'
                , url: '/system/house/house/importExcel' //改成您自己的上传接口
                ,accept: 'file'
                , done: function (res) {
                    //如果上传失败
                    if (res.code > 0) {
                        return layer.msg('上传失败');
                    }
                    //上传成功
                    layer.msg('上传成功')
                }
            });
        });
    </script>

     <!-- 导入区域 -->
     <script id="importTpl" type="text/template">
         <form enctype="multipart/form-data" class="mt20 mb10">
             <div class="col-xs-offset-1">
                 <input type="file" id="file" name="file"/>
                 <font color="red" class="pull-left mt10">
                     提示：仅允许导入“zip”格式文件！
                 </font>
             </div>
         </form>
     </script>
</body>
</html>